{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="标题"/>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="banner_status" class="layui-input">
                                <option value="">不限状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="banner_where" class="layui-input">
                                <option value="">不限位置</option>
                                <option value="1">品牌页轮播图</option>
                                <option value="2">案例页轮播图</option>
                                <option value="3">设计师页轮播图</option>
                                <option value="4">斑马客户轮播图</option>
                                <option value="5">客户推荐轮播图</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="banner_more" class="layui-input">
                                <option value="">不限独立轮播图位置</option>
                                <option value="0">正常轮播图</option>
                                <option value="1">产品推荐1轮播图</option>
                                <option value="2">产品推荐2轮播图</option>
                                <option value="3">产品推荐3轮播图</option>
                                <option value="4">产品推荐4轮播图</option>
                                <option value="5">产品推荐5轮播图</option>
                                <option value="6">案例推荐轮播图</option>
                                <option value="7">设计师推荐轮播图</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('bannerAdd')}');">
                            <i class="fa fa-plus"></i> 添加品牌页轮播图
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('bannerCaseAdd')}');">
                            <i class="fa fa-plus"></i> 添加案例页轮播图
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('bannerUserAdd')}');">
                            <i class="fa fa-plus"></i> 添加设计师页轮播图
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('bannerAdd2')}?where=4');">
                            <i class="fa fa-plus"></i> 添加斑马客户轮播图
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('bannerAdd2')}?where=5');">
                            <i class="fa fa-plus"></i> 添加客户推荐轮播图
                        </button>
                    </div>
                    <div class="input-group" >
                        {if $agid != 10}
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 主页面推荐里的独立轮播图设置 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll0">设为正常轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll1">设为主页面推荐产品1独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll2">设为主页面推荐产品2独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll3">设为主页面推荐产品3独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll4">设为主页面推荐产品4独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll5">设为主页面推荐产品5独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll6">设为主页面推荐案例独立轮播图</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="ppll7">设为主页面推荐设计师独立轮播图</a></li>
                        </ul>
                        {/if}
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        {{# if(d.banner_type == 1){ }}
                        <img src="{{d.banner_img}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                        {{# } }}
                        {{# if(d.banner_type == 2){ }}
                        <a href="{{d.banner_img}}" target="_blank" style="color: cornflowerblue">查看视频</a>
                        {{# } }}
                    </script>

                    <!--状态显示模板-->
                    <script type="text/html" id="statBar">
                        {{# if(d.banner_status == 1){ }}
                        上架中
                        {{# } }}
                        {{# if(d.banner_status == 2){ }}
                        已下架
                        {{# } }}
                    </script>
                    <script type="text/html" id="banner_where">
                        {{# if(d.banner_where == 1){ }}
                        品牌页轮播图
                        {{# } }}
                        {{# if(d.banner_where == 2){ }}
                        案例页轮播图
                        {{# } }}
                        {{# if(d.banner_where == 3){ }}
                        设计师页轮播图
                        {{# } }}
                        {{# if(d.banner_where == 4){ }}
                        客户管理轮播图
                        {{# } }}
                        {{# if(d.banner_where == 5){ }}
                        客户推荐轮播图
                        {{# } }}
                    </script>
                    <script type="text/html" id="banner_more">
                        {{# if(d.banner_more == 0){ }}
                        无
                        {{# } }}
                        {{# if(d.banner_more == 1){ }}
                        产品推荐1轮播图
                        {{# } }}
                        {{# if(d.banner_more == 2){ }}
                        产品推荐2轮播图
                        {{# } }}
                        {{# if(d.banner_more == 3){ }}
                        产品推荐3轮播图
                        {{# } }}
                        {{# if(d.banner_more == 4){ }}
                        产品推荐4轮播图
                        {{# } }}
                        {{# if(d.banner_more == 5){ }}
                        产品推荐5轮播图
                        {{# } }}
                        {{# if(d.banner_more == 6){ }}
                        案例推荐轮播图
                        {{# } }}
                        {{# if(d.banner_more == 7){ }}
                        设计师推荐轮播图
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        {{# if(d.banner_where == 1) { }}
                        <a href="javascript:;" onclick="wk.href('{:url('bannerEdit')}?banner_id={{d.banner_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        {{# } }}
                        {{# if(d.banner_where == 2) { }}
                        <a href="javascript:;" onclick="wk.href('{:url('bannerCaseEdit')}?banner_id={{d.banner_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        {{# } }}
                        {{# if(d.banner_where == 3) { }}
                        <a href="javascript:;" onclick="wk.href('{:url('bannerUserEdit')}?banner_id={{d.banner_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        {{# } }}
                        {{# if(d.banner_where == 4 || d.banner_where == 5) { }}
                        <a href="javascript:;" onclick="wk.href('{:url('bannerEdit2')}?banner_id={{d.banner_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        {{# } }}

                        {{# if(d.banner_status == 1) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.banner_id}}','{:url('bannerDown')}', '确定下架？')" class="btn btn-primary btn-xs m-r-xs" title="下架"><i class="fa fa-arrow-down">下架</i></a>
                        {{# } }}
                        {{# if(d.banner_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.banner_id}}','{:url('bannerOn')}', '确定上架？')" class="btn btn-danger btn-xs m-r-xs" title="上架"><i class="fa fa-arrow-up">上架</i></a>
                        {{# } }}
                        {{# if(d.banner_index == 1 && d.banner_where < 4){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.banner_id}}','{:url('indexshow')}','确定设为推荐在主页面显示吗?')" class="btn btn-primary btn-xs m-r-xs" title="设为推荐">设为推荐</a>
                        {{# } }}
                        {{# if(d.banner_index == 2 && d.banner_where < 4){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.banner_id}}','{:url('indexhide')}','确定取消推荐吗?')" class="btn btn-warning btn-xs m-r-xs" title="取消推荐">取消推荐</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.banner_id}}','{:url('bannerDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o">删除</i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Banner/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 60, title: '序号'}
                , {field: 'banner_title', width: '', title: '标题', align: 'center'}
                , {field: 'banner_img', width: 110, title: '缩略图/视频', align: 'center', templet: '#imgTpl'}
                , {field: 'banner_where', width: '', title: '位置', align: 'center', toolbar: '#banner_where'}
                , {field: 'banner_more', width: '', title: '独立轮播图位置', align: 'center', toolbar: '#banner_more'}
                , {field: 'banner_status', width: 80, title: '状态', align: 'center', toolbar: '#statBar'}
                , {field: 'banner_sort', width: 110, title: '排序(可编辑)', align: 'center', edit: 'test'}
                , {field: 'pp_name', width: '170', title: '所属品牌/案例/设计师', align: 'center'}
                , {field: 's_name', width: '110', title: '所属门店', align: 'center'}
                , {field: 'banner_time', width: 160, title: '新建时间', align: 'center'}
                , {fixed: 'right', width: 280, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });

        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            wk.change(data.banner_id,"{:url('updateSort')}",field,value);
        });
        var $ = layui.$, active = {
            //批量导出订单
            ppll0:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',0);
            },
            ppll1:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',1);
            },
            ppll2:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',2);
            },
            ppll3:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',3);
            },
            ppll4:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',4);
            },
            ppll5:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',5);
            },
            ppll6:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',6);
            },
            ppll7:function () {
                wk.change(getIds(),'{:url('ppll')}','banner_more',7);
            },

        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['banner_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>